package com.ruoyi.zxjd.work.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable7;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable7Service;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 纪检监察机关立案审查调查情况登记Controller
 *
 * @author lcc
 * @date 2021-03-04
 */
@Controller
@RequestMapping("/work/templatetable7")
public class WorkTemplateTable7Controller extends BaseController {
    private String prefix = "work/templatetable7";

    @Autowired
    private IWorkTemplateTable7Service workTemplateTable7Service;

    @RequiresPermissions("work:templatetable7:view")
    @GetMapping()
    public String templatetable7() {
        return prefix + "/templatetable7";
    }

    /**
     * 查询纪检监察机关立案审查调查情况登记列表
     */
    @RequiresPermissions("work:templatetable7:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WorkTemplateTable7 workTemplateTable7) {
        startPage();
        List<WorkTemplateTable7> list = workTemplateTable7Service.selectWorkTemplateTable7List(workTemplateTable7);
        return getDataTable(list);
    }

    /**
     * 导出纪检监察机关立案审查调查情况登记列表
     */
    @RequiresPermissions("work:templatetable7:export")
    @Log(title = "纪检监察机关立案审查调查情况登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WorkTemplateTable7 workTemplateTable7) {
        List<WorkTemplateTable7> list = workTemplateTable7Service.selectWorkTemplateTable7List(workTemplateTable7);
        ExcelUtil<WorkTemplateTable7> util = new ExcelUtil<WorkTemplateTable7>(WorkTemplateTable7.class);
        return util.exportExcel(list, "templatetable7");
    }

    /**
     * 新增纪检监察机关立案审查调查情况登记
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存纪检监察机关立案审查调查情况登记
     */
    @RequiresPermissions("work:templatetable7:add")
    @Log(title = "纪检监察机关立案审查调查情况登记", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WorkProgressBO workProgressBO) {
        return toAjax(workTemplateTable7Service.insertWorkTemplateTable7(workProgressBO));
    }

    /**
     * 修改纪检监察机关立案审查调查情况登记
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        WorkTemplateTable7 workTemplateTable7 = workTemplateTable7Service.selectWorkTemplateTable7ById(id);
        mmap.put("workTemplateTable7", workTemplateTable7);
        return prefix + "/edit";
    }

    /**
     * 查看保存纪检监察机关立案审查调查情况登记
     */
    @RequiresPermissions("work:templatetable7:edit")
    @Log(title = "纪检监察机关立案审查调查情况登记", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WorkTemplateTable7 workTemplateTable7) {
        return toAjax(workTemplateTable7Service.updateWorkTemplateTable7(workTemplateTable7));
    }

    /**
     * 删除纪检监察机关立案审查调查情况登记
     */
    @RequiresPermissions("work:templatetable7:remove")
    @Log(title = "纪检监察机关立案审查调查情况登记", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(workTemplateTable7Service.deleteWorkTemplateTable7ByIds(ids));
    }

    /**
     * 删除纪检监察机关立案审查调查情况登记
     */
    @RequiresPermissions("work:templatetable7:remove")
    @Log(title = "纪检监察机关立案审查调查情况登记", businessType = BusinessType.DELETE)
    @GetMapping("/remove")
    @ResponseBody
    public AjaxResult removeByGet(String ids) {
        return toAjax(workTemplateTable7Service.deleteWorkTemplateTable7ByIds(ids));
    }

    /**
     * 通过工作安排id查询 工作模板7 记录
     * 不分页,查所有
     */
    @RequiresPermissions("work:templatetable7:list")
    @PostMapping("/list/all")
    @ResponseBody
    public TableDataInfo allList(WorkTemplateTable7 workTemplateTable7) {
        List<WorkTemplateTable7> list = workTemplateTable7Service.selectWorkTemplateTable7List(workTemplateTable7);
        return getDataTable(list);
    }


    /**
     * 根据id查询模板7的内容,
     * 刷新并跳转到新增修改界面
     */
    @GetMapping("/view/{id}")
    public String showById(@PathVariable("id") Long id, ModelMap mmap) {
        WorkTemplateTable7 workTemplateTable7 = workTemplateTable7Service.selectWorkTemplateTable7ById(id);
        mmap.put("workTemplateTable7", workTemplateTable7);
//        return prefix + "/add";
        return "/system/user/user";
    }


}
